<template>
  <div class="search-table-wrapper">
    <div class="search-table-inner">
      <!-- 在它下面循环 -->
      <div
        class="search-book-table"
        @click="onClick(item)"
        v-for="(item, index) in data"
        :key="index"
      >
        <div class="book-img-wrapper">
          <ImageView :src="item.cover">
          </ImageView>
        </div>
        <div class="book-info-wrapper">
          <div class="book-title">{{item.title}}</div>
          <div class="book-info">
            <div class="book-author">{{item.author}}</div>
            <div class="book-category">{{item.categoryText}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import ImageView from '../base/ImageView'
export default {
  components: { ImageView },
  props: {
    data: Array
  },
  methods: {
    onClick (book) {
      this.$router.push({ path: '/pages/detail/main', query: { fileName: book.fileName } })
      this.$emit('onClick', book)
    }
  }
}
</script>

<style lang="scss" scoped>
.search-table-wrapper {
  margin: 20px 16px;
  .search-table-inner {
    .search-book-table {
      margin-top: 20px;
      display: flex;
      width: 100%;
      .book-img-wrapper {
        // BUG 这里样式还是有问题
        width: 70px;
      }
      .book-info-wrapper {
        width: 75%;
        margin-left: 15px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .book-title {
          width: 100%;
          font-size: 22px;
          color: #333333;
          line-height: 26px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          font-weight: 500;
        }
        .book-info {
          margin-bottom: 5px;
          .book-author {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-top: 5px;
            font-size: 18px;
            color: rgba(0, 0, 0, 0.65);
            line-height: 20px;
          }
          .book-category {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 18px;
            color: rgba(0, 0, 0, 0.45);
            line-height: 20px;
          }
        }
      }
    }
  }
}
</style>
